// 3.for of 场景

// 展开语法（）
const iterableObj={
    names:["abc","cba","nba"],
    [Symbol.iterator]:function () {
        let index = 0
        return {
            // 要用箭头函数才能拿到names
            next:()=> {
                if(index < this.names.length){
                    return {done:false,value:this.names[index++]}
                }else{
                    return {done:true,value:undefined}
                }
            }
        }
    }
}

const names = ["abc","cba","nba"]
const newNames = [...names,...iterableObj]
console.log(newNames)   